home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 1
/
Amiga Tools.iso
/
egs-tools
/
egs_demo-version
/
egs_devels
/
c-include
/
egs.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-06
|
19KB
|
558 lines
#ifndef EGS_EGS_H
#define EGS_EGS_H
/***************************************************************************\
* $
* $ FILE : egs.h
* $ VERSION : 1
* $ REVISION : 37
* $ DATE : 03-Feb-93 12:34
* $
* $ Author : mvk
* $
*****************************************************************************
* *
* (c) Copyright 1990/93 VIONA Development *
* All Rights Reserved *
* *
\***************************************************************************/
#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif
#ifndef EXEC_PORTS_H
#include <exec/ports.h>
#endif
/*
* This library is the basic interface to high resolution graphics cards.
* The hardware is almost completely encapsulated by this module. It is
* not allowed to access hardware registers directly.
*
* The library is designed for full multitasking support. Thus several
* programs can use the graphics card simultaneously. Screens can be
* switched like Intuition screens by pressing the left Amiga key and "S".
*
* Moreover, a separate mouse pointer is supported. The Amiga mouse and
* EGS mouse can be exchanged by pressing the left Amiga key and "A".
* If the mouse pointer is on the EGS screen, all key codes are redirected
* to the screen, too.
*
* EGS screens have a message system on their own so that applications with
* input processing can lack any window without losing multitasking
* capabilities.
*/
/*
* EMemNode, EMemPtr
*
* Graphics memory on the card is allocated by the procedure AllocEMem.
* The memory segments are held in EMemNode list structures. As graphics
* cards use almost only big consecutive segments, the EGS libraries possess
* memory management that can move memory in its address location. To
* inhibit memory running away while being used, the EMemNode must be locked
* by incrementing "lock", e.g. when loading "dest" into any address register.
* "lock" must be decremented after memory access. The address of the
* allocated graphics memory is located in the "dest" field.
* Only the fields "dest" and "lock" are public, all other fields are
* strictly private. Example:
*
* EMemNode mem;
* ...
* mem.lock++; now mem.dest may be used
* *mem.dest = $AA;
* ...(further memory accesses)...
* mem.lock--; now mem.dest may not be used any longer
*/
/* To access the "lock" component, you would have to use
"mynode.lock.false.lock", which is simply disgusting !
struct E_EMemNode {
APTR Dest;
union {
struct {
BYTE Lock;
UBYTE Display;
} false;
struct {
UWORD Moveable;
} true;
} Lock;
UWORD Pad_1;
LONG Size;
APTR Next, Prev;
};
But as "moveable" is private to the EGS library, I just ignore the
memory variation. If you want to test for moveable then test both
"lock" and "display".
*/
typedef struct E_EMemNode *E_EMemPtr;
struct E_EMemNode {
APTR Dest;
BYTE Lock;
UBYTE Display;
UWORD Pad_1;
LONG Size;
E_EMemPtr Next, Prev;
};
/*
* EViewPtr
*
* Opaque access to a view mode which contains only internal data that is
* not exported for reasons of compatibility.
*/
typedef APTR E_EViewPtr;
/*
* CLUEntry, CLU, CLUPtr
*
* The colour lookup table. The range of a colour component red, green or
* blue is 0 to 255, which means all 8 bits are used. The number of necessary
* table entries depends on the selected screen depth. If the CLUT is too
* short, the missing colours are selected by random. If no CLUT is
* specified, a standard CLUT is generated.
*/
struct E_CLUEntry {
UBYTE Red, Green, Blue, Dummy;
};
typedef struct E_CLUEntry E_CLU;
typedef E_CLU *E_CLUPtr;
/*
* EBitMapPtr, EBitMap
*
* Basic structure for management of graphics memory.
*
* As different graphic boards exist which have different memory organisations
* the egs libraries offer several different bitmap types.
*
* These are the fields that have the same meaning in any bitmap:
*
* .Width : Pixel Width.
* .Height : Pixel Height.
* .BytesPerRow : Number of bytes per row.
* .Depth : Number of bits for one pixel; though in 24 bit mode (real)
* the number 24 is contained herein, always 32 bits (one
* long word) are used.
*
* .Type : type of bitmap.
*
* The different types are:
*
* E_PIXELMAP : The memory format is chunky which means that the bits that
* build up one pixel lay in adjacent memory locations.
* E.g. 2 bits : aabbccdd eeffgghh iijjkkll ...
* The organisation in 24 bit is RGBx. This is the native egs
* bitmap type. You can allways get an map of these type in
* 24 bits. The functions in egsblit are allways able to work
* with this bitmap and convert from and to other 24 bit
* formats, or to other bit depths.
* The real location in memory is
*
* ..->Typekey.PixelMap.Planes.Dest
*
* The memory has to be locked before it is accessed or the
* pointer to it, as the libraries are able to move parts
* of the graphicsmemory to gain longer fragments.
* To lock increment the lock field, to unlock decrement it
* again. This lock does not guarantee exclusive access, it
* only guarantees, that the bitmap ist not moved.
*
* E_PIXLACEMAP : Some graphicsboards have in interlaced an splitted memory
* which means that the odd and the even field of the display
* reside in different memory locations. The format is the
* same as E_pixelMap, with one exception. The even lines
* are in one block and the odd lines are in one block. The
* starting location of the odd field is
*
* ..->Typekey.PixelMap.Planes.Dest+
* ..->Typekey.PixelMap.IntDisp
*
* E_BITPLANEMAP : The bits that build each pixel are spread over several
* bitplanes.
*
* E_USERMAP : Nothing is known about the structure of the frame store.
*
* E_PIXELMAP_xRGB : Same as E_PIXELMAP, exept that the format in 24 bit is
* xRGB and not RGBx.
*
* Your programms should be able to handle at least the E_PIXELMAP format. If
* it can't handle the format it is given, use the routines of the
* egsblit.library.
* If you need a bitmap for double buffering you should use the bitmap from
* your screen as friend bitmap and the flag E_EB_DISPLAYABLE.
*
*/
/*
Enumeration type for access to union fields
*/
#define E_PIXELMAP 0
#define E_PIXLACEMAP 1
#define E_BITPLANEMAP 2
#define E_USERMAP 3
#define E_PIXELMAP_xRGB 4
#define E_EB_DISPLAYABLE 1
#define E_EB_BLITABLE 2
#define E_EB_SWAPABLE 4
#define E_EB_NOTSWAPABLE 8
#define E_EB_CLEARMAP 16
typedef struct E_EBitMap *E_EBitMapPtr;
struct E_EBitMap {
WORD Width, Height, BytesPerRow;
BYTE Depth;
UBYTE Type; /* Enumeration type descriptor for access to union fields */
union {
struct {
struct E_EMemNode Planes;
ULONG IntDisp;
} PixelMap;
struct {
APTR BitPlanes [24];
} BitPlaneMap;
struct {
APTR Action;
} UserMap;
} Typekey;
};
/* Access example:
*
* E_EBitMapPtr Ptr;
* APTR Plane, Otherplane;
*
* if (Ptr->Type == E_BITPLANEMAP)
* {
* Plane = Ptr->Typekey.BitPlaneMap.BitPlanes[someindex];
* }
* if (Ptr-Type == E_PIXELMAP)
* {
* Otherplane = Ptr->Typekey.PixelMap.Planes.Dest;
* }
*
*/
/*
* SoftMousePtr, SoftMouse, HardMousePtr, HardMouse
*
* Data block for the mouse pointer. Three colours can be used. The bits of
* a pixel are consecutive as usually, the combination %00 represents a
* transparent pixel.
*
* The maximum size of a software mouse pointer is 32 by 32 pixels. A hard-
* ware mouse pointer can have up to 64 by 64 pixels but that would exceed
* the processor capabilities during emulation.
*
*
* EMouse, EMousePtr
*
* Definition structure for a mouse pointer. Each screen can have only one
* mouse pointer at any moment. When switching screens, the pointer is
* changed adequately. A screen's mouse pointer can be altered by a function
* at any time.
*
* For graphics cards without a hardware pointer a pointer is emulated by
* software. Specified HardMouse structures are used only if a hardware
* pointer was implemented, too. If .soft = NIL then the HardMouse structure
* is converted into a SoftMouse structure automatically.
*
* .Color1 : Colour for %01
* .Color2 : Colour for %10
* .Color3 : Colour for %11.
* These colours are supported only for 4 bit mode and higher.
* .XSpot,
* .YSpot : Displacement of the mouse pointer's click pixel.
* .Width,
* .Height : Width and Height of the SoftMouse.
* .Soft : Pointer to SoftMouse structure, should always be initia-
* lized for reasons of compatibility.
* .Hard : Pointer to HardMouse structure; if you always want to use
* the small mouse pointer this field should be NIL.
*
* Example: The standard mouse pointer.
*
* StdMouse= EMouse:(Color1=$00000001,Color2=$FF0000FF,Color3=$80000080,
* XSpot=1,YSpot=1,Width=25,Height=31,
* Soft=SoftMouse:(
* (%01010101000000000000000000000000,%00000000000000000000000000000000),
* (%01111111010101010000000000000000,%00000000000000000000000000000000),
* (%01111010111111110101010100000000,%00000000000000000000000000000000),
* (%01111111101010101111111101010101,%00000000000000000000000000000000),
* (%00011111111110101010101011110100,%00000000000000000000000000000000),
* (%00011111111111111110101011010000,%00000000000000000000000000000000),
* (%00011111111111111111111101000000,%00000000000000000000000000000000),
* (%00011111111111111111110100000000,%00000000000000000000000000000000),
* (%00010111111111111111101101000000,%00000000000000000000000000000000),
* (%00000111111111111111111011010100,%00000000000000000000000000000000),
* (%00000111111111111111111110111101,%00000000000000000000000000000000),
* (%00000111111111011111111111101111,%01000000000000000000000000000000),
* (%00000101111101010111111111111011,%11010100000000000000000000000000),
* (%00000001110101010101111111111110,%10111101000000000000000000000000),
* (%00000001010101010101111111111111,%11101011010000000000000000000000),
* (%00000001010101010101011111111111,%11111010110101000000000000000000),
* (%00000001010101010101010111111111,%11111111101111010000000000000000),
* (%00000001010101010101010101111111,%11111111111101000000000000000000),
* (%00000001010101010101010101111111,%11111111010100000000000000000000),
* (%00000000010101010001010101011111,%11111101000000000000000000000000),
* (%00000000010101000000010101010111,%11110101010000000000000000000000),
* (%00000000010100000000010101010101,%11110101010100000000000000000000),
* (%00000000010000000000000101010101,%11010101010101010000000000000000),
* (%00000000000000000000000001010101,%01010101010101010100000000000000),
* (%00000000000000000000000000010101,%01010101010101010000000000000000),
* (%00000000000000000000000000010101,%01010101010101000000000000000000),
* (%00000000000000000000000000000101,%01010101010000000000000000000000),
* (%00000000000000000000000000000001,%01010101000000000000000000000000),
* (%00000000000000000000000000000000,%01010101000000000000000000000000),
* (%00000000000000000000000000000000,%01010100000000000000000000000000),
* (%00000000000000000000000000000000,%00010000000000000000000000000000),
* (%00000000000000000000000000000000,%00000000000000000000000000000000))'PTR);
*/
typedef LONG E_HardMouse [64][4];
typedef E_HardMouse *E_HardMousePtr;
typedef LONG E_SoftMouse [32][2];
typedef E_SoftMouse *E_SoftMousePtr;
typedef struct E_EMouse *E_EMousePtr;
struct E_EMouse {
LONG Color1, Color2, Color3;
WORD XSpot, YSpot;
WORD Width, Height;
E_SoftMousePtr Soft;
E_HardMousePtr Hard;
};
/*
* EScrFlags, EScrFlagSet, EScreen, EScreenPtr, NewEScreen...
*
* EScreens are structures with capabilities as follows:
* - Management of resolution mode (EViewPtr)
* - Management of graphics memory (EBitMap)
* - Message system for user input
* Please note that an EScreen is different from the EGSIntui screens, i.e.
* NO window can be opened on any EScreen; for that purpose an EGSIntui screen
* must be created.
*
* EScrFlags
* SCREENBEHIND : The new screen is opened behind all other screens.
* OWNBITMAP : The screen has a user defined BitMap.
* LACESCREEN : The screen is to be opened as interlaced to decrease
* video line frequency in spite of knowing the flicker
* (currently without meaning).
*
* NewEScreen
* .Mode : Name of the selected video mode ending with a null byte.
* .Depth : Required bit depth (1, 2, 4, 6, 8, 12, 16 or 24).
* Allowed pixel depths depend on the underlying hardware,
* and may vary for different screen modes. The suggested
* way to retrieve data for supported modes and depths is
* by the use of 'E_GetHardInfo'.
* .Colors : An own CLUT if required; if NIL the standard CLUT is used.
* .Map : Possibly a user BitMap which has to be allocated
* previously.
* .Flags : Flags for the new screen (only "SCREENBEHIND").
* .Mouse : Possibly a user mouse pointer.
* .EdcmpFlags : Messages to be sent.
* .Port : Possibly an application message port; must be removed
* before closing the screen (or crash).
*/
/* Corresponding EScrFlagSet has 32 bits ! */
#define E_SCREENBEHIND 1
#define E_OWN_BITMAP 2
#define E_LACESCREEN 4
struct E_NewEScreen {
char *Mode;
UWORD Depth;
UWORD Pad_1;
E_CLUPtr Colors;
E_EBitMapPtr Map;
ULONG Flags;
E_EMousePtr Mouse;
ULONG EdcmpFlags;
struct MsgPort *Port;
};
/*
* EScreen
* .Prev,
* .Next : Internal chaining.
* .View : !!!! PRIVATE !!!!
* .Map : Pointer to the screen's BitMap structure.
* .Colors : !!!! PRIVATE !!!!
* .Mouse : EMouse structure (READ ONLY !!!!).
* .MouseOn : !!!! PRIVATE !!!!
* .EdcmpFlags : Message flags (READ ONLY !!!).
* .Port : Screen's message port.
* .BackLink : Link field for users, e.g. used by EGSIntui.
* .MouseX,
* .MouseY : Always the current mouse position on the screen.
*/
typedef struct E_EScreen *E_EScreenPtr;
struct E_EScreen {
E_EScreenPtr Prev, Next;
E_EViewPtr View;
E_EBitMapPtr Map;
E_CLUPtr Colors;
E_EMousePtr Mouse;
ULONG Flags;
UBYTE MouseOn;
UBYTE Pad_1;
UBYTE Pad_2;
UBYTE Pad_3;
ULONG EdcmpFlags;
struct MsgPort *Port;
APTR BackLink;
WORD MouseX, MouseY;
};
/*
* EDCMPFlags, EDCMPFlagSet, EGSMsgPtr, EGSMessage
*
* Structures for the message system working on the EScreen level. Thus
* mouse and character input can be gained without opening a window.
*
* EDCMPFlags:
* eMOUSEBUTTONS : Mouse buttons were pressed
* eMOUSEMOVE : Mouse was moved
* eRAWKEY : Key code from the keyboard
* eINTUITICK : Timer is calling
* eDISKINSERTED : Disk was inserted
* eDISKREMOVED : Disk was removed
* eNEWPREFS : Preferences have been changed
*
* .Class : Type of the message
* .Code : Message code (refer to "InputEvents")
* .Qualifier : Message code (refer to "InputEvents")
* .IAddress : (For E_eRAWKEY: Pointer to deadkey array )
* .MouseX,
* .MouseY : Mouse position
* .Second,
* .Micros : Event time
* .EdcmpScreen : Screen sending the message
*/
/* Corresponding EDCMPFlagSet has 32 bits ! */
#define E_eMOUSEBUTTONS 1
#define E_eMOUSEMOVE 2
#define E_eRAWKEY 4
#define E_eTIMETICK 8
#define E_eDISKINSERTED 16
#define E_eDISKREMOVED 32
#define E_eNEWPREFS 64
typedef struct E_EGSMessage *E_EGSMsgPtr;
struct E_EGSMessage {
struct Message Msg; /* has long word size */
ULONG Class;
UWORD Code;
UWORD Qualifier;
APTR IAddress;
WORD MouseX, MouseY;
ULONG Seconds, Micros;
E_EScreenPtr EdcmpScreen;
};
/*
* ScreenMode, ScreenModePtr
*
* Information on supported screen modes and depths. The list including
* these modes is found by 'GetHardInfo'.
*
* .ln_Name : The name of the mode, for use in 'E_OpenScreen' ...
* .Horiz : The horizontal resolution
* .Vert : The vertical resolution
* .Depths : The supported pixel depths in this mode. Each depth is
* represented in one bit. E.g. (1<<24) & mode->depths for
* 24 bit.
*/
typedef struct E_ScreenMode *E_ScreenModePtr;
struct E_ScreenMode {
struct Node Node;
UWORD Pad;
UWORD Horiz, Vert;
ULONG Depths;
};
/*
* To realize the highest possible compatibility between different graphics
* cards, the library must offer a function giving information about the
* current card plugged in. Among these information items are the resolutions
* that the card implements.
* That task is carried out by the HardInfo structure and the procedure
* "GetHardInfo".
*/
/* Corresponding HardInfoFlagSet has 32 bits ! */
#define E_HARD_BLITTER 1
#define E_HARD_BOOTROM 2
#define E_HARD_VBLANK 4
#define E_HARD_REALMODE 8
#define E_HARD_GAMMACORRECT 16
#define E_HARD_PLANES 32
typedef struct E_HardInfo *E_HardInfoPtr;
struct E_HardInfo {
char *Product, *Manufact, *Name;
WORD Version, MaxFreq;
ULONG Flags;
struct List *Modes;
WORD ActPixClock, FrameTime;
APTR MemBase;
LONG MemSize;
char *LibDate;
};
#endif /* EGS_EGS_H */